import { checkMaxDivideWtihNumber } from './common'
// `，过去4周共有咳嗽${attr19}天/喘息发作${attr20}次`
/**
 * 学龄前期
 * @param {*} attrs
 */
export function lessThanControLevel(attrs) {
  const { attr19, attr20, attr44, attr21, attr38 } = attrs
  const tmp = { attr1: '0', attr2: '0', attr3: '0', attr4: '0' }

  const result19_20 = checkMaxDivideWtihNumber(attr19, attr20)
  if (result19_20 != -1 && result19_20 <= 1) {
    tmp.attr1 = '1'
  } else if (result19_20 > 1) {
    tmp.attr1 = '2'
  }
  if (attr44 === '有') tmp.attr2 = '1'

  const result21 = checkMaxDivideWtihNumber(attr21, 0, true)

  if (result21 != -1 && result21 <= 1) {
    tmp.attr3 = '1'
  } else if (result21 > 1) {
    tmp.attr3 = '2'
  }
  console.log('attr38 =' + attr38)
  if (attr38 === '有') tmp.attr4 = '1'
  return tmp
}

/**
 * 学龄期
 * @param {*} attrs
 */
export function greaterEqualControLevel(attrs) {
  const { attr19, attr20, attr44, attr21, attr38 } = attrs
  const tmp = { attr1: '0', attr2: '0', attr3: '0', attr4: '0' }

  const result19_20 = checkMaxDivideWtihNumber(attr19, attr20)
  console.log('greaterEqual result19_20 =' + result19_20)
  if (result19_20 != -1 && result19_20 <= 2) {
    tmp.attr1 = '1'
  } else if (result19_20 > 2) {
    tmp.attr1 = '2'
  }

  if (attr44 === '有') tmp.attr2 = '1'

  const result21 = checkMaxDivideWtihNumber(attr21, 0, true)
  if (result21 != -1 && result21 <= 2) {
    tmp.attr3 = '1'
  } else if (result21 > 2) {
    tmp.attr3 = '2'
  }

  if (attr38 === '有') tmp.attr4 = '1'
  return tmp
}

// function checkMaxDivideWtihNumber(one, two, coefficient = 4) {
//   const number1 = one ? parseInt(one) : 0
//   const number2 = two ? parseInt(two) : 0

//   const maxNumber = Math.max(number1, number2)

//   return maxNumber ? maxNumber / coefficient : 0
// }
